home *** CD-ROM | disk | FTP | other *** search
- #!/usr/bin/perl
-
- $modLog = "/tmp/modprobe.log";
- $modErr = "/tmp/modprobe.err";
-
- #######################
- ### Loading rtc & agpgart modules...
- ######
- system "modprobe -s rtc >> $modLog 2>> $modErr";
- system "modprobe -s apm >> $modLog 2>> $modErr";
- system "modprobe -s agpgart >> $modLog 2>> $modErr";
-
- # load the OSS emulation module for systems that don't work with alsa
- system "modprobe -s snd-pcm-oss >> $modLog 2>> $modErr";
-
- system "modprobe -s supermount >> $modLog 2>> $modErr";
-
- ########################################
- ### Collecting info on your CD/DVD drive(s)
- ### We need the CD/DVD devices in lexical order, so we first
- ### make a note of all IDE devices available...
- #############
- $ideDir = "/proc/ide/";
- my @ideCDROMs;
- opendir IDE, $ideDir;
- while (my $drive = readdir IDE) {
- next unless $drive =~ /^hd\w$/;
- my $media = `cat $ideDir$drive/media`;
- chop $media;
- push @ideCDROMs, $drive if $media eq "cdrom";
- }
- closedir(IDE);
- ##############
- ### and then we sort them
- #############
- my @sortedIDEcdroms = sort @ideCDROMs;
- for ( my $i=0; $i < @sortedIDEcdroms; $i++ ) {
- my $model = `cat $ideDir$sortedIDEcdroms[$i]/model`;
- system "ln -s /dev/cdroms/cdrom$i /dev/dvd"
- if !-e "/dev/dvd" and $model =~ /dvd/i;
- push @cdDrives, $model;
- }
- ########################################
- ### Collecting info on your SCSI CD/DVD drive(s)
- ### should be ordered based on scsi id
- ### ATTENTION! this assumes that IDE drivers are
- ### always before SCSI drives in /dev/cdrom/cdroms[0-i]
- #############
- $scsiDir = "/proc/scsi/";
- my @scsiCDROMs;
- opendir SCSI, "$scsiDir";
- while (my $drive = readdir SCSI) {
- next unless $drive =~ /^scsi$/;
- my $model;
- open CONFIG, "$scsiDir$drive";
- while (<CONFIG>) {
- if ( /.*Type:.*CD-ROM.*/ ){
- push @scsiCDROMs, $model;
- next;
- }
- if ( /.*Model: (.*)Rev.*/ ){
- $model=$1;
- next;
- }
- }
- close CONFIG;
- }
- closedir SCSI;
- ##############
- ### now we sort them too
- #############
- my @sortedSCSIcdroms = sort @scsiCDROMs;
- ### Finally we use as default dvd player the first drive
- ### whose model name matches 'dvd'
- for ( my $i=@ideCDROMs; $i < @sortedSCSIcdroms+@ideCDROMs; $i++ ) {
- my $model = $sortedSCSIcdroms[$i-@ideCDROMs];
- push @cdDrives, $model;
- system "ln -s /dev/cdroms/cdrom$i /dev/dvd"
- if $model =~ /dvd/i and !-e "/dev/dvd";
- }
- ### let's make sure there's a /dev/dvd even though no such label has been found
- `ln -s /dev/cdroms/cdrom0 /dev/dvd` if !-e "/dev/dvd";
-
- ### Now, in case there's more than a CD/DVD drive we need to modify the MPlayer menu
- ### in order to provide a "Create playlist" item for each drive
- if( @cdDrives > 1 ){
- my $pls = "";
- for ( my $i=0; $i < @cdDrives; $i++ ) {
- $pls .= "\t<e name=\"" . truncateTo(20,$cdDrives[$i]) . "\" ok=\"loadcd $i\"/>\n";
- }
- $menu = `cat /root/.mplayer/menu.conf`;
- $menu =~ s/Play CD\" ok=\"loadcd 0/Play CD ...\" ok=\"set_menu drives/;
- $menu .= "\n\n<cmdlist name=\"drives\" title=\"CD/DVD Drives\" ptr=\"<>\" >\n";
- $menu .= $pls;
- $menu .= "</cmdlist>\n";
- open MENU, "> /root/.mplayer/menu.conf";
- print MENU $menu;
- close MENU;
- }
-
- sub truncateTo {
- my $n = shift;
- my $string = shift;
- $string =~ /^(.{1,$n})/;
- return $1;
- }
-